import java.util.Objects;

/**
 * @author ericfouh
 */
public class Similarities implements Comparable<Similarities> {
    /**
     *
     */
    private String file1;
    private String file2;
    private int count;


    /**
     * @param file1
     * @param file2
     */
    public Similarities(String file1, String file2) {

        // file1 should always be the one with the lower name
        if (file1.compareTo(file2) < 0) {
            this.file1 = file1;
            this.file2 = file2;
        } else {
            this.file1 = file2;
            this.file2 = file1;
        }

        this.setCount(0);
    }


    /**
     * @return the file1
     */
    public String getFile1() {
        return file1;
    }


    /**
     * @return the file2
     */
    public String getFile2() {
        return file2;
    }


    /**
     * @return the count
     */
    public int getCount() {
        return count;
    }


    /**
     * @param count the count to set
     */
    public void setCount(int count) {
        this.count = count;
    }


    @Override
    public int compareTo(Similarities o) {
        // Sort by file1, file2, count
        int i = this.file1.compareTo(o.file1);
        if (i != 0) {
            return i;
        }

        i = this.file2.compareTo(o.file2);
        if (i != 0) {
            return i;
        }

        return Integer.compare(o.count, this.count);
    }


    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Similarities that = (Similarities) o;
        return Objects.equals(file1, that.file1) && Objects.equals(file2, that.file2);
    }

    @Override
    public int hashCode() {
        return Objects.hash(file1, file2);
    }
}
